<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration {
    public function up(): void
    {
        Schema::create('scenic_order_goods', function (Blueprint $table) {
            $table->id();
            $table->uuid('user_id')->comment('用户id');
            $table->string('order_sn',32)->comment('系统订单号');
            $table->string('out_order_id',32)->default('')->comment('外部单号 冗余 考虑单笔订单多门票的情况');
            $table->string('scenic_id',32)->comment('景区id');
            $table->string('ticket_id',32)->comment('门票id');
            $table->string('play_at',16)->comment('游玩时间');
            $table->string('usage',64)->comment('使用方法 从预定须知里提取');
            $table->integer('enter_type')->comment('入园方式');
            $table->unsignedDecimal('price', 10, 2)->comment('商品价格');
            $table->integer('count')->comment('游客数量');
            $table->json('contact')->comment('联系人');
            $table->json('verification_certificate')->nullable()->comment('出票成功后,通过订单详情获取 凭证格式{txt,attachment[{type,value}]}');
            $table->timestamps();
            $table->unique(['order_sn','ticket_id'], 'unique_order_goods');

        });
    }

    public function down(): void
    {
        Schema::dropIfExists('scenic_order_goods');
    }
};
